import { Controller, Get } from '@midwayjs/decorator';
import {getDocument} from "pdfjs-dist";
const path = require("path")

@Controller('/')
export class HomeController {
  @Get('/')
  async home(): Promise<string> {

    const defaultPdfPath = "./未命名1_加水印.pdf"
    const loadingTask = getDocument(path.resolve(__dirname,defaultPdfPath))
    console.log(loadingTask)

    loadingTask.promise.then(function (pdf){
      console.log(pdf)
    // //   // pdf.getPage(1).then(function (page){
    // //   //   console.log(page)
    // //   // })
    }).catch(err=>{
      console.log('err',err)
    })
    return 'Hello Midwayjs!';
  }
}
